﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data;
using MySql.Data.MySqlClient;
using System.IO;
using System.Windows.Forms;
using DAL;
using Entities;

namespace BL
{
    public class ArticulosBLL
    {
        public static DataSet dt;
        public DataTable tblArticulos;
        public DataTable tblArticulosItems;
        public DataTable tblColores;
        public DataTable tblProveedores;
        public DataTable tblLocales;

        public static void CrearDataset(ref int? codigoError)
        {
            try
            {
                dt = DAL.ArticulosDAL.CrearDataset();
                dt.Tables[0].TableName = "Articulos";
                string strFilePath = Application.StartupPath + "\\Datasets_xml\\";
                dt.Tables["Articulos"].WriteXml(strFilePath + "Articulos.xml", XmlWriteMode.WriteSchema);
            }
            catch (MySqlException ex)
            {
                if (ex.Number == 1042) //no se pudo abrir la conexion por falta de internet
                {
                    codigoError = 1042;
                }
                else
                {
                    codigoError = ex.Number;
                }
            }
        }

        public static DataTable Buscar(DataTable tabla, TextBox txtParametros, string opcion)
        {
            DataTable buscados = DAL.ArticulosDAL.Buscar(tabla, txtParametros, opcion);
            return buscados;
        }

    }
}
